﻿//
//  Windows_libc
//
//  Created by  cc_team(陈旭，陈曦) qq:511272827.
//  Copyright 2011 cc_team. All rights reserved.
//
#ifndef CC_TIME_H
#define CC_TIME_H

#include <windows.h>

typedef long cc_clock_t;
typedef long cc_time_t;

#ifndef EPOCH_BIAS
#define EPOCH_BIAS  116444736000000000i64
#endif

#define CLOCKS_PER_SECOND			1000
#define MINUTE_SECONDS				60
#define HOUR_SECONDS				(60 * MINUTE_SECONDS)
#define DAY_SECONDS					(24 * HOUR_SECONDS)
// a common year seconds
#define YEAR_SECONDS				(365 * DAY_SECONDS)

// by default, the length of asctime returned str is 26.
#define ASCTIME_BUFSIZE				26

typedef struct cc_tm
{
	int sec;
	int min;
	int hour;
	int day;
	int month;
	int year;
	int wday;		// weekday, for example, Sunday
	int yday;		
	int isdst;
}cc_tm;

typedef union
{
	unsigned __int64 ft_scalar;
	FILETIME		 ft_struct;
}cc_FT;

#ifdef __cplusplus
extern "C" {
#endif
                       
// the return value is like: "Wed Jan 02 02:03:55 2011\n\0"
char * __cdecl cc_asctime(
	const cc_tm *tm
);

/*
struct cc_tm * __cdecl cc_localtime(
	const time_t *t
	);
*/

cc_time_t __cdecl cc_time(
	cc_time_t *tm
);

double __cdecl cc_difftime(
	cc_time_t t1,
	cc_time_t t2
);

cc_clock_t __cdecl cc_clock(
	void
);

#ifdef __cplusplus
}		// extern "C"
#endif

#endif